package com.xlhj.boot.webservice.rs.server.config;

import com.xlhj.boot.webservice.rs.api.service.UserInfoService;
import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: caijliu
 * @Date: 06/12/2021 14:24
 * @Description TODO
 * @Vsersion: 0.0.1
 */
@Configuration
public class CXFConfig {

    @Autowired
    private Bus bus;
    @Autowired
    private UserInfoService userInfoService;

    /**
     * 设置WebService访问父路径
     * @return
     */
    @Bean
    public Server createServer() {
        JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();
        factoryBean.setAddress("/userInfoService");
        factoryBean.setBus(bus);
        factoryBean.setServiceBean(userInfoService);
        return factoryBean.create();
    }
}
